#include "WorldEntity.h"

CWorldEntity::CWorldEntity(int indexGfx, const CVector2i& position, bool canCollide):m_indexGfx(indexGfx), 
				m_position(position), m_canCollide(canCollide), m_rectangleCollision(0, 0, 0, 0), 
				m_previousPosition(position), m_active(true), m_side(eSideNeutral), m_healthPoint(0), m_damagePoint(0){}

CWorldEntity::~CWorldEntity(){}

bool CWorldEntity::isCollidingWith(CWorldEntity* otherEntity)
{
	CRectangle otherCollisionRectangle = otherEntity->getCollisionRectangle();
	otherCollisionRectangle.translate(otherEntity->getPosition());

	CRectangle currentCollisionRectangle=m_rectangleCollision;
	currentCollisionRectangle.translate(m_position);
	return currentCollisionRectangle.intersectWith(otherCollisionRectangle);
}

CRectangle CWorldEntity::getCollisionRectangle(void)const
{
	return m_rectangleCollision;
}

bool CWorldEntity::getCanCollide(void)const
{
	return m_canCollide;
}

CVector2i CWorldEntity::getPosition(void)const
{
	return m_position;
}

void CWorldEntity::setPosition(const CVector2i& position)
{
	m_position = position;
}

void CWorldEntity::setActive(bool active)
{
	m_active = active;
}

bool CWorldEntity::getActive(void)const
{
	return m_active;
}

void CWorldEntity::setSide(eSide side)
{
	m_side = side;
}

eSide CWorldEntity::getSide(void)const
{
	return m_side;
}

int CWorldEntity::getHealthPoint(void)const
{
	return m_healthPoint;
}

void CWorldEntity::setHealthPoint(int hp)
{
	m_healthPoint = hp;
}

int CWorldEntity::getDamagePoint(void)const
{
	return m_damagePoint;
}

void CWorldEntity::setDamagePoint(int dp)
{
	m_damagePoint = dp;
}

void CWorldEntity::scrollEntity(const CVector2i& scrollVector)
{
	m_position=m_position + scrollVector;
}
